package com.itheima.ydd.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.itheima.ydd.common.ResultData;
import com.itheima.ydd.entity.YddUser;
import com.itheima.ydd.service.IYddUserService;
import com.itheima.ydd.service.impl.YddUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author author
 * @since 2022-05-22
 */
@RestController
@RequestMapping("/ydd_user")
public class YddUserController {

    @Autowired
    IYddUserService iYddUserService;

    @GetMapping("list")
    public ResultData pageList(String sex, String username, String mobile, String page, String limit) {
        return iYddUserService.pageList(sex, username, mobile, page, limit);
    }
    @GetMapping("del")
    public ResultData delByid(String id){
        iYddUserService.delByid(id);
        return ResultData.ok("删除成功",null);

    }
    @GetMapping("rowInfo")
    public ResultData rowInfo(String id){

        return ResultData.ok("查询成功",iYddUserService.rowInfo(id));

    }
    @PostMapping("add")
    public ResultData addUser(@RequestBody YddUser yddUser){
        iYddUserService.addUser(yddUser);
        return ResultData.ok("添加成功");

    }
    @PostMapping("update")
    public ResultData update(@RequestBody YddUser yddUser){
        iYddUserService.updateUser(yddUser);
        return ResultData.ok("修改成功",null);

    }
}
